// 事件模块
const EventEmitter = require('events')

class MyEventEmitter extends EventEmitter { }

const event = new MyEventEmitter()

event.on('play', (value) => {
  console.log(value);
})

event.on('play2', (value) => {
  console.log(value);
})

event.once('play3', (value) => {
  console.log(value);
})

event.emit('play', JSON.stringify({ name: 'mal', age: 18, event: 'play' }))
event.emit('play', JSON.stringify({ name: 'mal', age: 18, event: 'play' }))
event.emit('play2', JSON.stringify({ name: 'mal', age: 18, event: 'play2' }))
event.emit('play2', JSON.stringify({ name: 'mal', age: 18, event: 'play2' }))
event.emit('play3', JSON.stringify({ name: 'mal', age: 18, event: 'play3' }))
event.emit('play3', JSON.stringify({ name: 'mal', age: 18, event: 'play3' }))